package cn.vehicle.domains.vo.res.sysPermission;

import cn.vehicle.enums.ActiveEnum;
import cn.vehicle.enums.PermissionTypeEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;

@Data
@Schema(description = "权限查询响应结果")
public class SysPermissionRes {

    @Schema(name = "id", description = "权限ID")
    private Long id;

    @Schema(name = "permissionName", description = "权限名称")
    private String permissionName;

    @Schema(name = "permissionCode", description = "权限编码")
    private String permissionCode;

    @Schema(name = "permissionType", description = "权限类型（MENU-菜单、BUTTON-按钮、API-接口）")
    private String permissionType;

    @Schema(name = "permissionTypeDesc", description = "权限类型描述")
    private String permissionTypeDesc;

    @Schema(name = "parentId", description = "父权限ID")
    private Long parentId;

    @Schema(name = "status", description = "权限状态（ACTIVE-启用、INACTIVE-停用）")
    private String status;

    @Schema(name = "statusDesc", description = "状态描述")
    private String statusDesc;

    @Schema(name = "orderNum", description = "排序号")
    private Integer orderNum;

    @Schema(name = "createTime", description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    public void setPermissionType(String permissionType) {
        this.permissionType = permissionType;
        this.permissionTypeDesc = PermissionTypeEnum.valueOf(permissionType).getDesc();
    }

    public void setStatus(String status) {
        this.status = status;
        this.statusDesc = ActiveEnum.valueOf(status).getDesc();
    }
}